package com.chinawlx.wlxteacher;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.util.Log;

import org.greenrobot.greendao.AbstractDaoMaster;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseOpenHelper;
import org.greenrobot.greendao.database.StandardDatabase;
import org.greenrobot.greendao.identityscope.IdentityScopeType;


// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
 * Master of DAO (schema version 1): knows all DAOs.
 */
public class DaoMaster extends AbstractDaoMaster {
    public static final int SCHEMA_VERSION = 1;

    /** Creates underlying database table using DAOs. */
    public static void createAllTables(Database db, boolean ifNotExists) {
        wlx_userDao.createTable(db, ifNotExists);
        wlx_authDao.createTable(db, ifNotExists);
        wlx_configDao.createTable(db, ifNotExists);
        wlx_fileDao.createTable(db, ifNotExists);
        wlx_gradeDao.createTable(db, ifNotExists);
        wlx_grade_noticeDao.createTable(db, ifNotExists);
        wlx_grade_timelineDao.createTable(db, ifNotExists);
        wlx_homeworkDao.createTable(db, ifNotExists);
        wlx_homework_commentDao.createTable(db, ifNotExists);
        wlx_homework_statisticsDao.createTable(db, ifNotExists);
        wlx_messageDao.createTable(db, ifNotExists);
        wlx_org_classroomDao.createTable(db, ifNotExists);
        wlx_org_spaceDao.createTable(db, ifNotExists);
        wlx_scheduleDao.createTable(db, ifNotExists);
        wlx_schedule_additionDao.createTable(db, ifNotExists);
        wlx_schedule_changeDao.createTable(db, ifNotExists);
        wlx_statistics_student_classDao.createTable(db, ifNotExists);
        wlx_statistics_teacher_schedule_dayDao.createTable(db, ifNotExists);
        wlx_statistics_teacher_schedule_monthDao.createTable(db, ifNotExists);
        wlx_studentDao.createTable(db, ifNotExists);
        wlx_student_levelDao.createTable(db, ifNotExists);
        wlx_student_medalDao.createTable(db, ifNotExists);
        wlx_student_order_detailDao.createTable(db, ifNotExists);
        wlx_student_studyDao.createTable(db, ifNotExists);
        wlx_user_friendDao.createTable(db, ifNotExists);
        wlx_schedule_scoreDao.createTable(db, ifNotExists);
    }

    /** Drops underlying database table using DAOs. */
    public static void dropAllTables(Database db, boolean ifExists) {
        wlx_userDao.dropTable(db, ifExists);
        wlx_authDao.dropTable(db, ifExists);
        wlx_configDao.dropTable(db, ifExists);
        wlx_fileDao.dropTable(db, ifExists);
        wlx_gradeDao.dropTable(db, ifExists);
        wlx_grade_noticeDao.dropTable(db, ifExists);
        wlx_grade_timelineDao.dropTable(db, ifExists);
        wlx_homeworkDao.dropTable(db, ifExists);
        wlx_homework_commentDao.dropTable(db, ifExists);
        wlx_homework_statisticsDao.dropTable(db, ifExists);
        wlx_messageDao.dropTable(db, ifExists);
        wlx_org_classroomDao.dropTable(db, ifExists);
        wlx_org_spaceDao.dropTable(db, ifExists);
        wlx_scheduleDao.dropTable(db, ifExists);
        wlx_schedule_additionDao.dropTable(db, ifExists);
        wlx_schedule_changeDao.dropTable(db, ifExists);
        wlx_statistics_student_classDao.dropTable(db, ifExists);
        wlx_statistics_teacher_schedule_dayDao.dropTable(db, ifExists);
        wlx_statistics_teacher_schedule_monthDao.dropTable(db, ifExists);
        wlx_studentDao.dropTable(db, ifExists);
        wlx_student_levelDao.dropTable(db, ifExists);
        wlx_student_medalDao.dropTable(db, ifExists);
        wlx_student_order_detailDao.dropTable(db, ifExists);
        wlx_student_studyDao.dropTable(db, ifExists);
        wlx_user_friendDao.dropTable(db, ifExists);
        wlx_schedule_scoreDao.dropTable(db, ifExists);
    }

    /**
     * WARNING: Drops all table on Upgrade! Use only during development.
     * Convenience method using a {@link DevOpenHelper}.
     */
    public static DaoSession newDevSession(Context context, String name) {
        Database db = new DevOpenHelper(context, name).getWritableDb();
        DaoMaster daoMaster = new DaoMaster(db);
        return daoMaster.newSession();
    }

    public DaoMaster(SQLiteDatabase db) {
        this(new StandardDatabase(db));
    }

    public DaoMaster(Database db) {
        super(db, SCHEMA_VERSION);
        registerDaoClass(wlx_userDao.class);
        registerDaoClass(wlx_authDao.class);
        registerDaoClass(wlx_configDao.class);
        registerDaoClass(wlx_fileDao.class);
        registerDaoClass(wlx_gradeDao.class);
        registerDaoClass(wlx_grade_noticeDao.class);
        registerDaoClass(wlx_grade_timelineDao.class);
        registerDaoClass(wlx_homeworkDao.class);
        registerDaoClass(wlx_homework_commentDao.class);
        registerDaoClass(wlx_homework_statisticsDao.class);
        registerDaoClass(wlx_messageDao.class);
        registerDaoClass(wlx_org_classroomDao.class);
        registerDaoClass(wlx_org_spaceDao.class);
        registerDaoClass(wlx_scheduleDao.class);
        registerDaoClass(wlx_schedule_additionDao.class);
        registerDaoClass(wlx_schedule_changeDao.class);
        registerDaoClass(wlx_statistics_student_classDao.class);
        registerDaoClass(wlx_statistics_teacher_schedule_dayDao.class);
        registerDaoClass(wlx_statistics_teacher_schedule_monthDao.class);
        registerDaoClass(wlx_studentDao.class);
        registerDaoClass(wlx_student_levelDao.class);
        registerDaoClass(wlx_student_medalDao.class);
        registerDaoClass(wlx_student_order_detailDao.class);
        registerDaoClass(wlx_student_studyDao.class);
        registerDaoClass(wlx_user_friendDao.class);
        registerDaoClass(wlx_schedule_scoreDao.class);
    }

    public DaoSession newSession() {
        return new DaoSession(db, IdentityScopeType.Session, daoConfigMap);
    }

    public DaoSession newSession(IdentityScopeType type) {
        return new DaoSession(db, type, daoConfigMap);
    }

    /**
     * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} -
     */
    public static abstract class OpenHelper extends DatabaseOpenHelper {
        public OpenHelper(Context context, String name) {
            super(context, name, SCHEMA_VERSION);
        }

        public OpenHelper(Context context, String name, CursorFactory factory) {
            super(context, name, factory, SCHEMA_VERSION);
        }

        @Override
        public void onCreate(Database db) {
            Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION);
            createAllTables(db, false);
        }
    }

    /** WARNING: Drops all table on Upgrade! Use only during development. */
    public static class DevOpenHelper extends OpenHelper {
        public DevOpenHelper(Context context, String name) {
            super(context, name);
        }

        public DevOpenHelper(Context context, String name, CursorFactory factory) {
            super(context, name, factory);
        }

        @Override
        public void onUpgrade(Database db, int oldVersion, int newVersion) {
            Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables");
            dropAllTables(db, true);
            onCreate(db);
        }
    }

}
